css: Initialize value before calling compute function
authorBenjamin Otte <otte@redhat.com>
Sat, 14 Jan 2012 04:00:54 +0000 (05:00 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 2 Feb 2012 02:13:38 +0000 (03:13 +0100)
gtk/gtkcssstyleproperty.c
gtk/gtkcssstylepropertyimpl.c

index 9743b8821bbe52c61cd67495032ceb62920f18e1..348ea0d163edcfa49052d9267046ce62a054a09f 100644 (file)
@@ -287,7 +287,6 @@ gtk_css_style_property_real_compute_value (GtkCssStyleProperty *property,
                                            GtkStyleContext     *context,
                                            const GValue        *specified)
 {
-  g_value_init (computed, _gtk_style_property_get_value_type (GTK_STYLE_PROPERTY (property)));
   _gtk_css_style_compute_value (computed, context, specified);
 }
 
@@ -465,6 +464,8 @@ _gtk_css_style_property_compute_value (GtkCssStyleProperty *property,
   g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
   g_return_if_fail (G_IS_VALUE (specified));
 
+  g_value_init (computed, _gtk_css_style_property_get_computed_type (property));
+
   property->compute_value (property, computed, context, specified);
 }
 
index d41048f328f51d82d9497f032e029ee1e9e0b7d6..66e1df5e38063fe5a39dd3042dae597de2119485 100644 (file)
@@ -52,11 +52,6 @@ color_compute (GtkCssStyleProperty    *property,
                GtkStyleContext        *context,
                const GValue           *specified)
 {
-  g_value_init (computed, GDK_TYPE_RGBA);
-
-  /* for when resolvage fails */
-restart:
-
   if (G_VALUE_HOLDS (specified, GTK_TYPE_SYMBOLIC_COLOR))
     {
       GtkSymbolicColor *symbolic = g_value_get_boxed (specified);
@@ -92,8 +87,10 @@ restart:
         }
       else
         {
-          specified = _gtk_css_style_property_get_initial_value (property);
-          goto restart;
+          color_compute (property,
+                         computed,
+                         context,
+                         _gtk_css_style_property_get_initial_value (property));
         }
 
     }
@@ -446,7 +443,6 @@ css_image_value_compute (GtkCssStyleProperty    *property,
   if (image)
     image = _gtk_css_image_compute (image, context);
 
-  g_value_init (computed, GTK_TYPE_CSS_IMAGE);
   g_value_take_object (computed, image);
 }
 
@@ -465,7 +461,6 @@ compute_border_width (GtkCssStyleProperty    *property,
   style = _gtk_css_style_property_lookup_by_id (_gtk_css_style_property_get_id (property) - 1);
   border_style = g_value_get_enum (_gtk_style_context_peek_property (context, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (style))));
 
-  g_value_init (computed, G_TYPE_INT);
   if (border_style == GTK_BORDER_STYLE_NONE ||
       border_style == GTK_BORDER_STYLE_HIDDEN)
     g_value_set_int (computed, 0);